package com.ktwlsoft.archivemanage.domain.business.repositoryService.guiBusiness;

import java.util.Date;
import java.util.List;

import com.ktwlsoft.archivemanage.domain.dao.entity.Account;
import com.ktwlsoft.archivemanage.service.utils.SnowFlake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ktwlsoft.archivemanage.domain.dao.repository.guiBusiness.IGuimendListOptLogMapper;
import com.ktwlsoft.archivemanage.domain.dao.entity.guiBusiness.GuimendListOptLog;

/**
 * guimend_list_opt_log--业务指导操作日志业务层接口实现类
 *
 * @author zhuhe on 2020-04-30 10:50:41
 * @version 1.0
 */
@Service
public class GuimendListOptLogRepositoryService {
	
	@Autowired
	private IGuimendListOptLogMapper guimendListOptLogMapper;

    /**
 	 * 查询分页 on 2020-04-30 10:50:41
 	 * @param pn 第几页
     * @param pageSize 每页多少条
 	 * @param guimendListOptLog guimendListOptLog
 	 * @return PageInfo<GuimendListOptLog>
 	 */
	public PageInfo<GuimendListOptLog> findPage(int pn,int pageSize,GuimendListOptLog guimendListOptLog) {
		PageHelper.startPage(pn,pageSize);
		PageInfo<GuimendListOptLog> pageInfo = new PageInfo<GuimendListOptLog>(guimendListOptLogMapper.findList(guimendListOptLog));
		return pageInfo;
	}

    /**
	 * 查询集合 on 2020-04-30 10:50:41
	 * @param guimendListOptLog guimendListOptLog
	 * @return List<GuimendListOptLog>
	 */
	public List<GuimendListOptLog> findList(GuimendListOptLog guimendListOptLog) {
		return guimendListOptLogMapper.findList(guimendListOptLog);
	}

    /**
	 * 根据ID查询信息 on 2020-04-30 10:50:41
	 * @param id	主键
	 * @return GuimendListOptLog
	 */
	public GuimendListOptLog getById(Long id){
		return guimendListOptLogMapper.getById(id);
	}

   /**
	 * 新增 on 2020-04-30 10:50:41
	 * @param guimendListOptLog guimendListOptLog
	 * @return int
	 */
	public int insert(GuimendListOptLog guimendListOptLog){
		return guimendListOptLogMapper.insert(guimendListOptLog);
	}

	/**
	 * 批量插入 2020-04-30 10:50:41
	 *
	 * @param list list
	 * @return int
	 */
	public int manyInsert(List<GuimendListOptLog> list){
	    return guimendListOptLogMapper.manyInsert(list);
	}

   /**
	 * 修改 on 2020-04-30 10:50:41
	 * @param guimendListOptLog guimendListOptLog
	 * @return int
	 */
	public int update(GuimendListOptLog guimendListOptLog){
		return guimendListOptLogMapper.update(guimendListOptLog);
	}

   /**
	 * 根据id集合批量删除信息 on 2020-04-30 10:50:41
	 * @param guimendListOptLogArr	主键编号集合
	 * @return int
	 */
	public int deleteByIds(List<Long> guimendListOptLogArr){
		return guimendListOptLogMapper.deleteByIds(guimendListOptLogArr);
	}

   /**
	 * 根据id删除信息 on 2020-04-30 10:50:41
	 * @param id id
	 * @return int
	 */
	public int deleteById(Long id){
		return guimendListOptLogMapper.deleteById(id);
	}

	/**
	  * 新增 on 2020/4/30 11:07
	  *
	  * @param mendListId 指导整改id
	  * @param operation 操作
	  * @param account account
	  * @return int
	  */
	public int save(Long mendListId, String operation, Account account) throws Exception{
		return insert(GuimendListOptLog.builder()
				.id(SnowFlake.getNextId())
				.guiMendId(mendListId)
				.optDate(new Date())
				.operator(account.getRealName())
				.operatorId(account.getId())
				.operation(operation).build());
	}
}
